package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.service.OfficialWebSiteService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @描述 运营管理平台-->官网配置
 * @创建人 zm
 * @创建时间 2020/7/9
 */
@RestController
@RequestMapping("/admin")
public class OfficialWebSiteController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private OfficialWebSiteService siteService;

    /**
     * @描述 查询官网幻灯片
     * @创建人 zm
     * @创建时间 2020/7/10
     */
    @RequestMapping("/queryCarouselAll")
    public Result queryCarouselAll() {
        return siteService.queryCarouselAll();
    }

    /**
     * @描述 修改幻灯片
     * @创建人 zm
     * @创建时间 2020/7/10
     */
    @RequestMapping("/updateCarouselById")
    public Result updateCarouselById(@RequestParam(value = "id") Integer id,
                                     @RequestParam(value = "sort", required = false) Integer sort) {
        return siteService.updateCarouselById(id, sort);
    }


    /**
     * @描述 添加幻灯片
     * @创建人 zm
     * @创建时间 2020/7/10
     */
    @RequestMapping("/addCarousel")
    public Result addCarousel(@RequestParam(value = "url") String url,
                              @RequestParam(value = "link", required = false) String link,
                              @RequestParam(value = "sort", required = false) Integer sort) {
        return siteService.addCarousel(url, link, sort);
    }

    /**
     * @描述 删除幻灯片
     * @创建人 zm
     * @创建时间 2020/7/10
     */
    @RequestMapping("/delCarouselById")
    public Result delCarouselById(@RequestParam(value = "id") Integer id) {
        return siteService.delCarouselById(id);
    }

    /**
     * @描述 删除应用
     * @创建人 zm
     * @创建时间 2020/7/10
     */
    @RequestMapping("/delApplyById")
    public Result delApplyById(@RequestParam(value = "id") Integer id) {
        return siteService.delApplyById(id);
    }

    /**
     * @描述 添加应用
     * @创建人 zm
     * @创建时间 2020/7/13
     */
    @RequestMapping("/addApply")
    public Result addApply(@RequestParam(value = "icon", required = false) String icon,//图标
                           @RequestParam(value = "name", required = false) String name,//名字
                           @RequestParam(value = "englishName", required = false) String englishName,//名字
                           @RequestParam(value = "sort", required = false) Integer sort,//排序 权重
                           @RequestParam(value = "url", required = false) String url,//图片rul
                           @RequestParam(value = "introduction", required = false) String introduction) {//简介
        return siteService.addApply(icon, name, sort, url, introduction, englishName);
    }

    /**
     * @描述 修改应用
     * @创建人 zm
     * @创建时间 2020/7/13
     */
    @RequestMapping("/updateApplyById")
    public Result updateApplyById(@RequestParam(value = "id") Integer id,
                                  @RequestParam(value = "icon", required = false) String icon,//图标
                                  @RequestParam(value = "name", required = false) String name,//名字
                                  @RequestParam(value = "englishName", required = false) String englishName,//名字
                                  @RequestParam(value = "sort", required = false) Integer sort,//排序 权重
                                  @RequestParam(value = "url", required = false) String url,//图片rul
                                  @RequestParam(value = "introduction", required = false) String introduction) {//简介
        return siteService.updateApplyById(id, icon, name, sort, url, introduction, englishName);
    }

    /**
     * @描述 按条件查询所有应用
     * @创建人 zm
     * @创建时间 2020/7/13
     */
    @RequestMapping("/queryApplyAll")
    public Result queryApplyAll(@RequestParam(value = "indexNo", required = false, defaultValue = "1") Integer indexNo,
                                @RequestParam(value = "rows", required = false, defaultValue = "20") Integer rows,
                                @RequestParam(value = "name", required = false) String name) {
        return siteService.queryApplyAll(indexNo, rows, name);
    }


    /**
     * @描述 删除标签
     * @创建人 zm
     * @创建时间 2020/7/10
     */
    @RequestMapping("/delLabel")
    public Result delLabel(@RequestParam(value = "id") Integer id) {
        return siteService.delLabel(id);
    }


    /**
     * @Author zm
     * @Description 添加标签
     * @Date 2020/9/2 16:32
     */
    @RequestMapping("/addLabel")
    public Result addLabel(@RequestParam(value = "type", required = false) String type,//类型
                           @RequestParam(value = "name", required = false) String name,//名字
                           @RequestParam(value = "englishName", required = false) String englishName,//名字
                           @RequestParam(value = "optionList", required = false) String optionList,
                           @RequestParam(value = "introduction", required = false) String introduction) {//简介
        return siteService.addLabel(type, name, optionList, introduction, englishName);
    }


    @RequestMapping("/addAbout")
    public Result addAbout(@RequestParam(value = "about", required = false) String about) {//简介
        return siteService.addAbout(about);
    }


    /**
     * @Author zm
     * @Description 查询标签
     * @Date 2020/9/3 9:40
     */
    @RequestMapping("/queryLabel")
    public Result queryLabel() {
        return siteService.queryLabel();
    }


    /**
     * @Author zm
     * @Description 查询关于我们
     * @Date 2020/9/3 9:40
     */
    @RequestMapping("/queryAbout")
    public Result queryAbout() {
        return siteService.queryAbout();
    }


    /**
     * @Author zm
     * @Description 查询地图使用
     * @Date 2020/9/7 15:46
     */
    @RequestMapping("/queryMap")
    public Result queryMap(@RequestParam(value = "keywords", required = false) String keywords) {
        return siteService.httpRequest(keywords);
    }
}
